struct TCOLORED_VERTEX
{
	float x, y, z;
	unsigned long color;
	static inline unsigned short GetVertexType()
	{
		return VERTEX_TYPE_GEOMETRY|VERTEX_TYPE_DIFFUSE;
	}
	static inline unsigned int GetFVF()
	{
		return D3DFVF_XYZ|D3DFVF_DIFFUSE;
	}
};



LPDIRECT3DVERTEXBUFFER9 g_pVB;

TCOLORED_VERTEX g_Vtxs[6]={{2.0f,8.0f,0.0f, 0xffffffff},
	{6.0f,8.0f,0.0f, 0xffffffff},
	{2.0f,3.0f,0.0f, 0xffffffff},
	{6.0f,8.0f,0.0f, 0xffffffff},
	{2.0f,3.0f,0.0f, 0xffffffff},
	{6.0f,3.0f,0.0f, 0xffffffff}
};


//initializing VertexBuffer VRAM
	if( FAILED( d3dDevice->CreateVertexBuffer( 6*sizeof(TCOLORED_VERTEX),
			0 /*Usage*/, TCOLORED_VERTEX::GetFVF(), D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
		return E_FAIL;

	VOID* pVertices;

	if(FAILED(g_pVB->Lock(0, sizeof(TCOLORED_VERTEX)*6, 
			(BYTE**)&pVertices, 0 ) ) ) 
		return E_FAIL;

	memcpy(pVertices, g_Vtxs, sizeof(TCOLORED_VERTEX)*6);
	g_pVB->Unlock();

//Rendering VertexBuffer VRAM
		d3dDevice->SetFVF(TCOLORED_VERTEX::GetFVF());
		d3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(TCOLORED_VERTEX));
		d3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
		
		
		
		
		
		
		
		
		
		
		
		
LPDIRECT3DVERTEXBUFFER9 g_pVB;
LPDIRECT3DINDEXBUFFER9 g_pIB;

TCOLORED_VERTEX g_Vtxs[4]={{2.0f,8.0f,0.0f, 0xffffffff},
	{6.0f,8.0f,0.0f, 0xffffffff},
	{2.0f,3.0f,0.0f, 0xffffffff},
	{6.0f,3.0f,0.0f, 0xffffffff}
};

unsigned short g_Idxs[6]={0,1,2,2,1,3};


//initializing VertexBuffer VRAM
	if( FAILED( d3dDevice->CreateVertexBuffer( 4*sizeof(TCOLORED_VERTEX),
			0 /*Usage*/, TCOLORED_VERTEX::GetFVF(), D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
		return E_FAIL;

	VOID* pVertices;

	if(FAILED(g_pVB->Lock(0, sizeof(TCOLORED_VERTEX)*4, 
			(BYTE**)&pVertices, 0 ) ) ) 
		return E_FAIL;

	memcpy(pVertices, g_Vtxs, sizeof(TCOLORED_VERTEX)*4);
	g_pVB->Unlock();
	
	if( FAILED( d3dDevice->CreateIndexBuffer( 6*sizeof(unsigned short),
			0 /*Usage*/, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIB, NULL ) ) )
		return E_FAIL;

	VOID* pVertices;

	if(FAILED(g_pIB->Lock(0, sizeof(unsigned short)*4, 
			(BYTE**)&pVertices, 0 ) ) ) 
		return E_FAIL;

	memcpy(pVertices, g_Idxs, sizeof(unsigned short)*4);
	g_pIB->Unlock();

//Rendering VertexBuffer and IndexBuffer VRAM
		d3dDevice->SetFVF(TCOLORED_VERTEX::GetFVF());
		d3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(TCOLORED_VERTEX));
		d3dDevice->SetIndices(g_IB);
		d3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
		
		
//Rendering VertexBuffer from RAM
	d3dDevice->SetFVF(TCOLORED_VERTEX::GetFVF());
	d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, g_Vtxs, sizeof(TCOLORED_VERTEX));
	
//Rendering VertexBuffer and IndexBuffer from RAM
	d3dDevice->SetFVF(TCOLORED_VERTEX::GetFVF());
	d3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, g_Idxs, D3DFMT_INDEX16, g_Vtxs, sizeof(TCOLORED_VERTEX));